<?PHP
include("../config/connect.php");
include("../public/common.php");

$id = CheckUrlParamNoDie("id");
$nPage = CheckUrlParamNoDie("page");

if($nPage == "")
	$nPage = 0;
	
if( $id == "")
{
	echo "error";
	exit;
}

// Normal
$count = mysql_num_rows(mysql_query("select id from report_items where (handle_code=0 or handle_code=1) and outer_code='".$id."'"));

$PAGE_SIZE = 6;
$limit = " limit ". $nPage*$PAGE_SIZE .",$PAGE_SIZE";
$sql = "select trade_id,pay_time,commission,handle_code from report_items where (handle_code=0 or handle_code=1) and outer_code='".$id."' order by pay_time desc".$limit;
$result = mysql_query( $sql );

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	font-size: 12px;
	color: #000;
	font-family: 宋体;
}
</style>
</head>

<body style="margin-left:0; margin-top:0; margin-right:0; margin-bottom:0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
      <tr bgcolor="#F4D662">
        <td width="151" height="24" align="center"><strong>序号</strong></td>
        <td width="244" align="center"><strong>成交日期</strong></td>
        <td width="197" align="center"><strong>订单号</strong></td>
        <td width="205" align="center"><strong>返现额</strong></td>
        <td width="422" align="center"><strong>状态</strong></td>
      </tr>
      <?PHP 
	  $i = $PAGE_SIZE * $nPage + 1;
	  if ($count > 0){
	  while( $result && $row = mysql_fetch_assoc( $result )) {
	  ?>
      <tr bgcolor="<?PHP if ($i % 2 == 0) echo "#EAE7BB"; else echo "#EEEEEE" ?>">
        <td height="24" align="center"><?PHP echo $i; ?></td>
        <td align="center"><?PHP echo $row["pay_time"]; ?></td>
        <td align="center"><?PHP echo substr($row["trade_id"], 0, 8)."**".substr($row["trade_id"], 10, 4); ?></td>
        <td align="center"><?PHP echo "￥".round($row["commission"] * 0.6, 2); ?></td>
        <td align="center"><?PHP if ($row["handle_code"] == 0) echo "<img src='images/clock.gif'>&nbsp;待确认"; else echo "<img src='images/accept.gif'>&nbsp;已返现"; ?></td>
      </tr>
      <?PHP
	  $i++;
		}
		}
		else
		{
			echo "<tr><td align='center'>暂时没有数据</td></tr>";
		}
		?>
</table>
<div>
<table width="100%" cellspacing="4">
  <tr>
<td>&nbsp;如果您是刚确认收货，请耐心等待，一般30分钟左右就能显示待确认的订单</td>

<td align="right">
<?PHP if ($count > $PAGE_SIZE) {?>
<a href="?page=0&id=<?PHP echo $id; ?>">首页</a>&nbsp;&nbsp;
<?PHP if ($nPage > 0) {?>
<a href="?page=<?PHP echo $nPage-1; ?>&id=<?PHP echo $id; ?>">上一页</a>&nbsp;&nbsp;
<?PHP } ?>
<?PHP if ($nPage < intval($count / $PAGE_SIZE)) {?>
<a href="?page=<?PHP echo $nPage+1; ?>&id=<?PHP echo $id; ?>">下一页</a>&nbsp;&nbsp;
<?PHP } ?>
<a href="?page=<?PHP echo intval($count / $PAGE_SIZE); ?>&id=<?PHP echo $id; ?>">尾页</a>&nbsp;&nbsp;
<?PHP } ?>
</td>

</tr></table>

</div>

</body>
</html>

